import React, { Component } from 'react';
/* 
   withRouter方法可以把一般组件 变成路由组件 拥有固定的props属性值
*/
import { withRouter } from 'react-router-dom';


class Header extends Component {
    render() {
        return (
            <div className="row">
                <div className="col-xs-offset-2 col-xs-8">
                    <div className="page-header">
                        <h2>React Router Demo</h2>
                        <button onClick={this.forward}>前进</button>
                        <button onClick={this.back}>后退</button>
                        <button onClick={this.go}>go</button>
                    </div>
                </div>
            </div>
        )
    }

    forward = () => {
        this.props.history.goForward();
    }
    back = () => {
        this.props.history.goBack();
    }
    go = () => {
        this.props.history.go(-1);
    }
}

export default withRouter(Header);
